package com.qbw.app.module.common.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import com.qbw.app.model.Country;
import com.qbw.app.module.common.holder.CountryAreaItemHolder;

/**
 * @author QBW
 * @date 2019/9/16
 */
public class CountryAreaAdapter extends CommonAdapter {

    public CountryAreaAdapter(Context context) {
        super(context);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        RecyclerView.ViewHolder viewHolder;
        switch (viewType) {
            case ViewType.VT_COUNTRY_AREA_ITEM:
                viewHolder = new CountryAreaItemHolder(mContext, parent);
                break;
            default:
                viewHolder = super.onCreateViewHolder(parent, viewType);
                break;
        }
        return viewHolder;
    }

    @Override
    public int getItemViewType(Object t) {
        if (t instanceof Country) {
            return ViewType.VT_COUNTRY_AREA_ITEM;
        }
        return super.getItemViewType(t);
    }

    private static class ViewType {
        public static final int VT_COUNTRY_AREA_ITEM = 1;
    }
}
